
#include <dirent.h>
#include <stdio.h>
#include <cstring>
#include <string>
#include <sys/stat.h>

using namespace std;

bool isDirectory(string path){
	struct stat statbuf;
	int isDir = 0;

	if (stat(path.c_str(), &statbuf) != -1) {
	   if (S_ISDIR(statbuf.st_mode)) {
	      return true;
	   }
	} else {
	      return false;
	}
}

void listDir(string path, string tabs){
	DIR *dir;
	struct dirent *ent;
	dir = opendir (path.c_str());
	while ((ent = readdir (dir)) != NULL) {
		printf ("%s%s\n", tabs.c_str(), ent->d_name);

		if(isDirectory(ent->d_name)){
			if(string(ent->d_name) == ".") continue;
			if(string(ent->d_name) == "..") continue;
			string v = path + string(ent->d_name) + "/";
			printf("%s\n", (tabs + v).c_str());
			listDir(v, tabs + "\t");

		}
	}
}

int main(){
	listDir("./", "");
}

